package com.wxm.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.xm.dao.ComdeDaoImp;
import com.xm.dao.LianXiDaoImpl;
import com.xm.entity.Comdetail;
import com.xm.entity.LianXi;

/**
 * 联系我们页面调用方法 Servlet implementation class MapServlet
 */
@WebServlet("/MapServlet")
public class MapServlet extends BaseServlet {
	/**
	 * 联系我们页面调用方法
	 * 地址http://localhost:8080/javaweb-Furniture/MapServlet?method=grtContact
	 * 
	 * @param req
	 * @param resp
	 * @throws ServletException
	 * @throws IOException
	 */
	public void grtContact(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		// 单个公司信息
		ComdeDaoImp dao = new ComdeDaoImp();
		Comdetail com = dao.getCom();

		// 单个联系信息
		LianXiDaoImpl dao3 = new LianXiDaoImpl();
		LianXi com2 = dao3.getCom().get(0);

		// 存储作用域
		HttpSession session = req.getSession();
		session.setAttribute("com", com);
		session.setAttribute("com2", com2);
		// 跳转页面（请求转发）
		req.getRequestDispatcher("contact.jsp").forward(req, resp);
	}

	/**
	 * 修改地图坐标方法 地址http://localhost:8080/javaweb-Furniture/MapServlet?method=toIndex
	 */
	public void toIndex(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		// 单个公司信息
		ComdeDaoImp dao = new ComdeDaoImp();
		Comdetail com = dao.getCom();
		// 存储作用域
		HttpSession session = req.getSession();
		session.setAttribute("com", com);
		// 跳转页面（请求转发）

		req.getRequestDispatcher("map.jsp").forward(req, resp);
	}
}
